package com.thunder.soft.ui.adapter;

import android.content.Intent;
import android.view.View;

import androidx.annotation.NonNull;

import com.thunder.soft.R;
import com.thunder.soft.bean.SystemArticleBean;
import com.thunder.soft.common.base.BaseAdapter;
import com.thunder.soft.common.base.BaseViewHolder;
import com.thunder.soft.databinding.AdapterSystemItemBinding;
import com.thunder.soft.ui.activity.SystemItemDetailActivity;

import java.util.List;

public class SystemItemAdapter extends BaseAdapter<SystemArticleBean, AdapterSystemItemBinding> {
    @Override
    protected int layoutId(int viewType) {
        return R.layout.adapter_system_item;
    }

    @Override
    protected void onBindHolder(AdapterSystemItemBinding binding, @NonNull BaseViewHolder<AdapterSystemItemBinding> holder,
                                int position, @NonNull SystemArticleBean data, List<Object> payloads) {

        super.onBindHolder(binding, holder, position, data, payloads);

        binding.articleItem.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(view.getContext(), SystemItemDetailActivity.class);
                intent.putExtra("link",getData(position).getLink());
                view.getContext().startActivity(intent);
            }
        });

        binding.setSystemArticleBean(getData(position));
        binding.executePendingBindings();
    }
}